package com.fanxuankai.boot.generator.autoconfigure;

import com.fanxuankai.boot.generator.CodeGenerator;
import com.fanxuankai.boot.generator.service.GeneratorService;
import com.fanxuankai.boot.generator.strategy.TemplateGenerator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author fanxuankai
 */
@EnableConfigurationProperties({CodeGeneratorProperties.class})
@ComponentScan(basePackageClasses = {GeneratorService.class, TemplateGenerator.class})
public class CodeGeneratorAutoConfiguration {
    @Bean
    @ConditionalOnProperty(name = CodeGeneratorProperties.ENABLED)
    public CodeGenerator codeGenerator(GeneratorService service, CodeGeneratorProperties properties) {
        return new CodeGenerator(service, properties);
    }
}